`
https://leetcode.cn/problems/valid-anagram/
`

/**
 * @param {string} s
 * @param {string} t
 * @return {boolean}
 */
var isAnagram = function (s, t) {
  const counter1 = counter(s)
  const counter2 = counter(t)
  for (let i = 0; i < counter1.length; i++) {
    if (counter1[i] !== counter2[i]) {
      return false
    }
  }

  return true
};

function counter(s) {
  const count = new Array(26).fill(0)
  for (const c of s) {
    const idx = c.charCodeAt(0) - 'a'.charCodeAt(0)
    count[idx]++
  }
  return count
}